use crate::entities::{setmeal::Model as SetmealModel, setmeal_dish::Model as SetmealDish};

use rust_decimal::Decimal;
use sea_orm::prelude::DateTime;
use serde::{Deserialize, Serialize};

#[derive(Debug, Deserialize, Serialize)]
pub struct SetmealCountVO {
    total: u64,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SetmealVO {
    pub id: Option<i64>,                  // 套餐 ID
    pub category_id: Option<i64>,         // 分类 ID
    pub name: Option<String>,             // 套餐名称
    pub price: Option<Decimal>,           // 套餐价格
    pub status: Option<i32>,              // 状态 0:停用, 1:启用
    pub description: Option<String>,      // 描述信息
    pub image: Option<String>,            // 图片路径
    pub update_time: Option<DateTime>,    // 更新时间
    pub category_name: Option<String>,    // 分类名称
    pub setmeal_dishes: Vec<SetmealDish>, // 套餐和菜品的关联关系
}

impl From<SetmealModel> for SetmealVO {
    fn from(setmeal: SetmealModel) -> Self {
        Self {
            id: Some(setmeal.id), // 直接使用，无需包裹 `Some`
            name: Some(setmeal.name),
            category_id: Some(setmeal.category_id),
            price: Some(setmeal.price),
            image: setmeal.image,
            description: setmeal.description,
            status: setmeal.status,
            update_time: setmeal.update_time,
            category_name: None,        // 默认 `None` 或实际逻辑赋值
            setmeal_dishes: Vec::new(), // 默认空 Vec 或实际逻辑赋值
        }
    }
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DeleteResult {
    pub success: Vec<i64>,
    pub failed: Vec<i64>,
}
